﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace OA.Model
{
    /// <summary>
    /// 权限列表
    /// </summary>
    public class Button : Base
    {

        public virtual int ID { get; set; }

        /// <summary>
        /// 权限代号
        /// </summary>
        public virtual string Code { get; set; }

        /// <summary>
        /// 菜单编号
        /// </summary>
        public virtual string MenuCode { get; set; }

        /// <summary>
        /// 菜单
        /// </summary>
        public virtual Model.Menu Menu { get; set; }

        /// <summary>
        /// 站点编号
        /// </summary>
        public virtual string WebSiteCode { get; set; }

        /// <summary>
        /// 站点
        /// </summary>
        public virtual WebSite WebSite { get; set; }

        /// <summary>
        /// 权限名称
        /// </summary>
        public virtual string Name { get; set; }

        /// <summary>
        /// 权限设置
        /// </summary>
        public virtual IList<Model.Authority> Authoritys { get; set; }

        #region 联合主键重写方法
        public override bool Equals(object obj)
        {
            var ret = false;
            Button model = obj as Button;
            if (model != null)
            {
                if (model.Code == this.Code && model.MenuCode == this.MenuCode && model.WebSiteCode==this.WebSiteCode)
                {
                    ret = true;
                }
            }
            return ret;
        }

        public override int GetHashCode()
        {
            return (this.WebSiteCode + "_" + this.MenuCode + "_" + this.Code).GetHashCode();
        }
        #endregion
    }
}
